package com.nickstumpos.android.easyVolume.events.service;

import com.nickstumpos.android.easyVolume.events.recievers.ApplyPresetBlueToothHsReciever;
import com.nickstumpos.android.easyVolume.events.recievers.ApplyPresetOnBootStateReciever;
import com.nickstumpos.android.easyVolume.events.recievers.ApplyPresetHeadsetReciever;

import android.app.Service;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.IBinder;
import android.util.Log;


public class EventTriggerService extends Service {
private ApplyPresetHeadsetReciever hsr;
private ApplyPresetBlueToothHsReciever btr;
private ApplyPresetOnBootStateReciever dkr;
	@Override
	public IBinder onBind(Intent arg0) {
		// TODO Auto-generated method stub
		return null;
	}
	@Override
  public void onCreate() {
          /* register receiver */
      hsr = new ApplyPresetHeadsetReciever(); 
      dkr = new ApplyPresetOnBootStateReciever(); 
      IntentFilter hsInf = new IntentFilter();
      hsInf.addAction(Intent.ACTION_HEADSET_PLUG);
      registerReceiver(hsr, hsInf);
      IntentFilter btInf = new IntentFilter();
			try {
				Class.forName("android.bluetooth.BluetoothDevice");
	      btr = new ApplyPresetBlueToothHsReciever();
	      btInf.addAction(
	          android.bluetooth.BluetoothDevice.ACTION_ACL_CONNECTED);
	      btInf.addAction(
	          android.bluetooth.BluetoothDevice.ACTION_ACL_DISCONNECTED);
	      registerReceiver(btr, btInf);
			} catch (ClassNotFoundException e) {
				Log.i("EasyVol","BluetoothUnavailable");
			}
      IntentFilter dInf = new IntentFilter();
      dInf.addAction(Intent.ACTION_BOOT_COMPLETED);
      registerReceiver(dkr, dInf);
  }
@Override
  public void onDestroy() {
          unregisterReceiver(hsr);
  } 
}
